package com.bsu.ascm;

import android.app.Activity;
import android.content.pm.ActivityInfo;
import android.os.Bundle;
import android.util.Log;
import android.view.KeyEvent;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Toast;

import com.bsu.ascm.operation.Login;
import com.bsu.ascm.operation.MainMenu;
import com.bsu.ascm.tool.AscmEnvironment;
import com.bsu.ascm.tool.Utils;

public class Ascm extends Activity {
	private Login login = null;
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);						//设置横屏
        requestWindowFeature(Window.FEATURE_NO_TITLE);											//无title  
        getWindow().setFlags(WindowManager.LayoutParams. FLAG_FULLSCREEN ,    					//全屏
                       WindowManager.LayoutParams. FLAG_FULLSCREEN);
        
    	AscmEnvironment.getInstance().setDisplayHeight(this.getWindowManager().getDefaultDisplay().getHeight());		//获得屏幕高度
    	AscmEnvironment.getInstance().setDisplayWidth(this.getWindowManager().getDefaultDisplay().getWidth());			//获得屏幕宽度

        this.setContentView(R.layout.mainscreen);	
        login = new Login(this);															//初始化登录控制对象
    }

    @Override
	protected void onResume() {
		// TODO Auto-generated method stub
		super.onResume();
		login.appLogin();
	}

	/**
     * 处理按键事件
     */
    @Override
    public boolean onKeyDown(int keyCode,KeyEvent event){
    	switch(keyCode){
    	case KeyEvent.KEYCODE_MENU:
    		super.openOptionsMenu();
    		break;
    	case KeyEvent.KEYCODE_BACK:											//当前layout为主界面时弹出退出界面
   			Utils.appExit(this);
    		break;
    	default:
    		break;
    	}
		return true;
    }
}